﻿<Window x:Class="Mengsk.ProxyDelivery.App.UI.Goods.GoodsSkuEditWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:metrocontrols="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:local="clr-namespace:Mengsk.ProxyDelivery.App.UI.Goods"
        Title="GoodsSkuEditWindow" Height="900" Width="1000" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded">

    <Window.Resources>
        <Style x:Key="clearTextBoxStyle" TargetType="{x:Type TextBox}"
                               BasedOn="{StaticResource MetroTextBox}">
            <Setter Property="metrocontrols:TextboxHelper.ClearTextButton" Value="True"></Setter>
            <Style.Triggers>
                <Trigger Property="metrocontrols:TextboxHelper.HasText"
                                         Value="False">
                    <Setter Property="metrocontrols:TextboxHelper.ClearTextButton"
                                            Value="False" />
                    <Setter Property="metrocontrols:TextboxHelper.Watermark"
                                            Value="" />
                </Trigger>
                <Trigger Property="metrocontrols:TextboxHelper.HasText"
                                         Value="True">
                    <Setter Property="metrocontrols:TextboxHelper.ClearTextButton"
                                            Value="True" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Column="1" Orientation="Horizontal">
            <TextBlock Text="鞋子版本：" Margin="3" VerticalAlignment="Center"></TextBlock>
            <TextBox Text="默认版本" Margin="3" Name="tbEdtion0" VerticalAlignment="Center" Width="100" IsReadOnly="True"/>
            <TextBox Text="" Margin="3" Name="tbEdtion1" Style="{StaticResource clearTextBoxStyle}" VerticalAlignment="Center" Width="100" TextChanged="tbEdtion_TextChanged"    />
            <TextBox Text="" Margin="3" Name="tbEdtion2" Style="{StaticResource clearTextBoxStyle}" VerticalAlignment="Center" Width="100" TextChanged="tbEdtion_TextChanged"  />
            <TextBox Text="" Margin="3" Name="tbEdtion3" Style="{StaticResource clearTextBoxStyle}" VerticalAlignment="Center" Width="100" TextChanged="tbEdtion_TextChanged"  />
            <TextBox Text="" Margin="3" Name="tbEdtion4" Style="{StaticResource clearTextBoxStyle}" VerticalAlignment="Center" Width="100" TextChanged="tbEdtion_TextChanged"  />
            <TextBox Text="" Margin="3" Name="tbEdtion5" Style="{StaticResource clearTextBoxStyle}" VerticalAlignment="Center" Width="100" TextChanged="tbEdtion_TextChanged"/>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <TextBlock Text="颜色种类：" Margin="3" VerticalAlignment="Top"></TextBlock>
            <ListBox  Name="lstColorTypes" Grid.Column="1" Margin="3"  Width="920"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                                     ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel></WrapPanel>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <CheckBox Name="chkColor" Checked="chkColor_Checked" Unchecked="chkColor_Unchecked" Margin="3" IsChecked="{Binding IsChecked}">
                                        <StackPanel Orientation="Horizontal" Width="100">
                                            <Rectangle Width="16" Height="16" Margin="1" >
                                                <Rectangle.Fill>
                                                    <SolidColorBrush Color="{Binding Source.Color}"></SolidColorBrush>
                                                </Rectangle.Fill>
                                            </Rectangle>
                                            <TextBox Text="{Binding Title}" Margin="1" Width="80" VerticalAlignment="Center" IsEnabled="{Binding IsChecked, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}}" />
                                        </StackPanel>
                                    </CheckBox>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

        </StackPanel>


        <Grid Grid.Row="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="选择尺码:" Margin="3" VerticalAlignment="Center"/>
            <ListBox Grid.Column="1" VerticalAlignment="Center" Name="lstSizes">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel></WrapPanel>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <CheckBox Name="chkSize" Margin="3" IsChecked="{Binding IsChecked}" Checked="chkSize_Checked" Unchecked="chkSize_Unchecked"   Content="{Binding Size}">
                                    </CheckBox>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </Grid>

        <GroupBox Header="SKU列表"  Grid.Row="4" >
            <ListBox Name="lstSkus" Margin="3"  ScrollViewer.CanContentScroll="False">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Grid >
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Grid.Column="0" Text="{Binding Edtion}" Margin="3" VerticalAlignment="Center" Width="120"/>
                                        <DataGrid Grid.Column="1" GridLinesVisibility="All" ItemsSource="{Binding ShoesSkus}" AutoGenerateColumns="False" IsReadOnly="False" SelectionMode="Single" SelectionUnit="FullRow" CanUserAddRows="False" CanUserSortColumns="False" CanUserReorderColumns="False">
                                            <DataGrid.Columns>
                                                <DataGridTextColumn Header="颜色" Binding="{Binding Color}" IsReadOnly="True"/>
                                                <DataGridTextColumn Header="尺码" Binding="{Binding Size}" IsReadOnly="True"/>
                                                <DataGridTextColumn Header="线上价格" Binding="{Binding Price}"/>
                                                <DataGridTextColumn Header="线下价格" Binding="{Binding OffLinePrice}"/>
                                            </DataGrid.Columns>
                                        </DataGrid>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </GroupBox>
        
        <Button Grid.Row="5" Name="btnSave" Margin="3" Content="保存" Click="btnSave_Click" HorizontalAlignment="Center" Width="80"/>
    </Grid>
</Window>
